import {ajax} from '../lib/ajax.js';

let txt_username = document.getElementById('txt_username');
let txt_password = document.getElementById('txt_password');
let btnLogin = document.getElementById('btnLogin');
let spLogin = document.getElementById('spLogin');

btnLogin.addEventListener('click',() => {
  spLogin.innerHTML = '';
  let user ={
    username:txt_username.value,
    password:txt_password.value,
  };
  ajax.post('/auth',user,(data) => {
    spLogin.innerHTML = data.message;

    if(data.success) {
      location.href = 'main.html';
    }
  });

});